<?php
$source_url = $_POST['url'];  //This could be anything URL source including stripslashes($_POST['url'])
 
$url = "http://api.facebook.com/restserver.php?method=links.getStats&urls=".$source_url;
$xml = file_get_contents($url);
$xml = simplexml_load_string($xml);
$shares =  $xml->link_stat->share_count;
$likes =  $xml->link_stat->like_count;
$comments = $xml->link_stat->comment_count;
$total = $xml->link_stat->total_count;
$max = max($shares,$likes,$comments);


$miurl=parse_url($source_url);
$query=$miurl['query'];
$aux = explode('=',$query);
$id = $aux[1];


include("handler_bd.php");
$conn->query("UPDATE propiedades SET popularidad = ".$total." WHERE id=".$id.";");
?>